﻿<div id="pagecontent">
<div id="add" style="cursor:pointer; float:right; font-weight:bold; color:#FF0066;"><span style="text-decoration:overline"><?php echo $this->lang->line('action_new'); ?></span> <img  src="<?php echo base_url(); ?>assets/img/icon-32-new.png" title="<?php echo $this->lang->line('m_addmenu'); ?>" align="absmiddle"/> </div>
<?php 
	$job_cate_id=$this->uri->segment(4);
	if($this->session->flashdata('message')!='')
	{ 
		
?>
<div id="sponsorAdDiv" style="visibility:hidden">
<table width="305px" height="50px" bgcolor="#FF0000"><tr><td>
<table width="300px" height="45px" bgcolor="#FFFFCC"><tr><td align="center" valign="middle">
<?php echo $this->session->flashdata('message'); ?>
</p>
</td></tr></table></td></tr></table>
</div>
<?php
	}
?>
<div id="addcontent">
  <div id='addmenu'> 
<form action="<?php echo base_url().index_page(); ?>/adminpage/cpanel/addnew_menu/" method="post" name="adminForm" id="adminForm" autocomplete="off" enctype="multipart/form-data">
    <fieldset style="border:none">
    <div id="addnew">
      <div>
        <label for="citemname"><?php echo $job_cate_id>0? "Menu Item Name":"Menu category Name"; ?></label>
        <input id="citemname" name="itemname" type="text" size="50" maxlength="50" value=""/>
      </div>
	   <?php 
  if ($job_cate_id >0)
  {
  	?>
	<div>
        <label for="citemname">Price</label>
        <input id="price" name="price" type="text" size="20" maxlength="12" value=""/>&nbsp;Example: 125.45
      </div>
	<?php	
  }
  ?>
       <div>
        <label for="csort">Sorting</label>
        <input id="csort" name="sort" type="text" size="5" maxlength="4" value="1"/>
      </div>
    </div>
    <input type="hidden" name="id" value="<?php echo $job_cate_id; ?>" />
    <input type="hidden" name="component" value="com_category" />
    <input type="hidden" name="option" value="add_job_category" />
    <input type="hidden" name="myurl" value="<?php echo base_url().index_page().$this->uri->uri_string(); ?>" />
    <input type="hidden" name="task" value="" />
    <div class="toolbar"  align="center">
      <table width="100px" border="0" align="center" cellpadding="5">
        <tr>
          <td align="center"><a onclick="javascript: submitbutton('save')" href="#"><span class="icon-32-save" title="<?php echo $this->lang->line('save'); ?>"> </span><?php echo $this->lang->line('save'); ?></a></td>
          <td align="center"><a onclick="document.adminForm.reset()" href="#"><span class="icon-32-cancel" title="<?php echo $this->lang->line('reset'); ?>"> </span><?php echo $this->lang->line('reset'); ?></a></td>
        </tr>
      </table>
    </div>
  </fieldset>
</form>
  </div> 
</div>
<div id="listmenu" align="center" style="width:80%; padding-left:100px;"> 
<table width="100%" id="tablesorter-demo" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
  <thead>
  <tr>
  <?php 
  if ($job_cate_id >0)
  {
  	echo '<th align="center" width="70%">Menu Items</th>';
	
  }
  else
  {
  	echo '<th align="center" width="70%">Menu category (Click to show items inside)</th>';
  }
  ?>
    <th align="center" width="10%">Ordering</th> 
    <th align="center" width="20%" class="{sorter: false}"><?php echo $this->lang->line('table_header_action'); ?></th>
  </tr>
  </thead>
  <tbody>
   <?php 
   				$i=0;
				foreach($menu_manager as $menu)
				{
					$td_bg=($i%2==0)?"":" background-color:#f0f0f6";
					if ($job_cate_id >0)
					  {
						$showname="<p><span class='nameoftitle'>".$menu['name']."</span></p>";
						
						echo "<tr><td style='padding-left:35px;".$td_bg.";'>".$showname."</td><td style='padding-left:35px;".$td_bg.";'>".$menu['sorting']."</td><td  style='padding-left:10px;".$td_bg.";' align='center'><a style='color:#FF6600;cursor:pointer'  href='".base_url().index_page()."/adminpage/cpanel/show_menu_detail/".$menu['product_id']."/".$job_cate_id."?height=130&width=600&modal=true' class='thickbox'>Edit</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a style='cursor:pointer' onclick='checkdelete(".$menu['product_id'].",".$job_cate_id.")'>Delete</a></td></tr>";
					  }
					  else
					  {
						$showname="<a href='".base_url().index_page()."/adminpage/cpanel/menu_manager/".$menu['category_id']."'><p style='cursor:pointer;' title='Click to go'><span class='nameoftitle'>".$menu['name']."</span></p></a>";
						echo "<tr><td style='padding-left:35px;".$td_bg.";'>".$showname."</td><td style='padding-left:35px;".$td_bg.";'>".$menu['ordering']."</td><td  style='padding-left:10px;".$td_bg.";' align='center'><a style='color:#FF6600;cursor:pointer'  href='".base_url().index_page()."/adminpage/cpanel/show_menu_detail/".$menu['category_id']."?height=130&width=600&modal=true' class='thickbox'>Edit</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a style='cursor:pointer' onclick='checkdelete(".$menu['category_id'].",0)'>Delete</a></td></tr>";
					  }
					  
					
					
				}
	?> 
  </tbody>
</table>
<div align="left" style="padding-left:35px; font-weight:bold; font-size:14px; "><a style="color:#F63; text-decoration:none" href="<?php echo base_url().index_page()."/adminpage/cpanel/menu_manager/"; ?>"><?php echo $job_cate_id>0? "<< Go back ---":""; ?></a></div>
  </div> 
</div>
<script>
function show_category_desc(id)
{
	$.ajax(
	{	
		type: "POST",
		url: "<?php echo base_url().index_page(); ?>/adminpage/cpanel/category_description/"+id,
		success: function(result)
		{
			$("#child"+id).html(result);
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}
	});
}

  $(document).ready(function(){
    $("#addmenu").hide();
	//$("img#vietnam").addClass('activelanguage');
    $("#add").click(function () {
	  //$("#addmenu").show('slow');
	  $('#addmenu').toggle(400); // First click should toggle to 'show'
      return false;

    });
  });

function checkdelete(id,category)
{	
	var value = confirm("<?php echo $this->lang->line('meg_confirm') ?>");
	if (value==false)
	{
		return;
	}
	else
	{
		location.href='<?php echo base_url().index_page()."/adminpage/cpanel/delete_menu/"; ?>'+id+'/'+category;
	}
}


function checkvalidate() 
{
	if (document.getElementById("citemname").value == "")
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('email_error'); ?>";
		return 0;
	}
	else
	{
		return 1;
	}
}
</script>
